import * as http from 'http';

const hostname = 'localhost';
const port = 3000;

/** 创建服务器，参数为请求处理函数 */
const server = http.createServer((req:http.IncomingMessage, res) => {
  console.log("接收到请求")
  console.log(req.url)
  console.log(req)
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World!\n');
});

/** 服务器开始监听，调用钩子 */
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});